package com.raylu.day03basic;

import com.raylu.utils.IntSource;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Example1SumUsage2 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        DataStreamSource<Integer> source = env.addSource(new IntSource());

        source
                .keyBy(r -> true)
                .sum(0)
                .print("sum value: ");

        source
                .keyBy(r -> true)
                .max(0)
                .print("max value: ");

        env.execute();
    }
}